tests: USB port-level RF reset between matrix cells#78
Merged
Conversation
Adds usb_port_power_cycle(dut): writes 0 then 1 to /sys/bus/usb/devices/<id>/authorized with a 0.5 s gap and a 2 s settle. Called at the start of _ensure_dut_location, so every cell starts with the DUT's RF state at chip-reset defaults regardless of what the previous cell left behind. Why this is needed: libusb_reset_device and sysfs unbind/rebind do NOT reset Realtek RF analog state — values written to RF registers survive both. Without the port-level cycle, canary captures of e.g. RF[A]/[B] 0x18 retain band-select bits from the previous session, turning per-cell comparisons into noise. Verified empirically on RTL8814AU while validating the PHY_SwitchWirelessBand8814A port: fresh-chip captures vs prior-session-state captures differ in bit 16 of RF 0x18 and bit 15 of RF 0x00 simply because the chip never fully powered down between runs. Adds ~3 s per DUT per cell (2.5 s settle + the 0.5 s gap). Cycle is default-on and can be opted out with --no-rf-reset for trivial smoke runs where the perf hit isn't worth it. Smoke-tested on the host 8814 sysfs path — single cycle took 3.34 s and the device re-enumerated cleanly afterward. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
4e075c2 to
0888d67
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds `usb_port_power_cycle(dut)` to `tests/regress.py` — toggles the USB port's `authorized` sysfs flag to force a chip-power cycle between matrix cells. Called from `_ensure_dut_location` so every cell starts with the DUT's RF state at chip-reset defaults regardless of what the previous cell left behind.
Why
`libusb_reset_device` and sysfs unbind/rebind do NOT reset Realtek RF analog state — values written to RF registers survive both. Without the port-level cycle, canary captures and matrix cells inherit RF state (band-select bits, IQK coefficients, AGC indices) from the previous run on the same DUT.
Verified empirically on RTL8814AU during the 8814A channel-set chain work: fresh-chip-cycle captures showed RF[A] 0x18 bit 16 (band-select) and RF[A] 0x00 bit 15 (LNA mode) reproducibly clean. Without the cycle, those bits drifted run-to-run.
Cost
Adds ~3 s per DUT per cell (0.5 s deauthorize gap + 2 s re-enumerate settle). Opt-out via `--no-rf-reset` for trivial smoke runs.
Test plan